import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/// 屏幕适配
abstract class YJSize {
  // 初始化设计稿尺寸
  static const double _screenWidth = 375.0;
  static const double _screenHeight = 812.0;

  /// 初始化 设置尺寸（填写设计中设备的屏幕尺寸）
  static init(BuildContext context,
      {bool splitScreenMode = false,
      bool minTextAdapt = false,
      bool scaleByHeight = false}) {
    ScreenUtil.init(context,
        designSize: const Size(_screenWidth, _screenHeight),
        // scaleByHeight: scaleByHeight,
        splitScreenMode: splitScreenMode,
        minTextAdapt: minTextAdapt);
  }

  /// 当前设备宽度
  static double get screenWidth => ScreenUtil().screenWidth;

  /// 当前设备高度
  static double get screenHeight => ScreenUtil().screenHeight;

  /// 状态栏高度 dp 刘海屏会更高
  static double get statusBarHeight => ScreenUtil().statusBarHeight;

  /// 底部安全区距离 dp
  static double get bottomBarHeight => ScreenUtil().bottomBarHeight;

  /// 默认dp是宽度适配
  static double dp(double width) => width.w;

  /// 获取 计算后的字体
  static double sp(double value) => value.sp;

  /// 获取 计算后的高度
  static double h(double value) => value.h;

  /// 获取 计算后的宽度
  static double w(double value) => value.w;

  /// 获取 计算后的圆角
  static double r(double value) => value.r;

  // ===============Layout自定义尺寸===============
  /// 文本字体
  static final double SP_10 = sp(10);
  static final double SP_12 = sp(12);
  static final double SP_14 = sp(14);
  static final double SP_16 = sp(16);
  static final double SP_18 = sp(18);
  static final double SP_20 = sp(20);
  static final double SP_22 = sp(22);
  static final double SP_24 = sp(24);
  static final double SP_26 = sp(26);
  static final double SP_28 = sp(28);
  static final double SP_30 = sp(30);
  static final double SP_32 = sp(32);
  static final double SP_34 = sp(34);
  static final double SP_36 = sp(36);
  static final double SP_38 = sp(38);

  /// 卡片或者板块之间，间距固定为10
  static final double DIVIDER = 10.w;

  /// 卡片或者块之间 内边距
  static final double LAYOUT_PADDING_16 = 16.w;

  /// 卡片或者块之间 内边距
  static final double LAYOUT_PADDING_8 = 8.w;

  /// 卡片或者块之间 内边距
  static final double LAYOUT_PADDING_4 = 4.w;

  /// 按钮-小
  static final double SMALL = dp(28);

  /// 按钮-中
  static final double MEDIUM = dp(32);

  /// 按钮-大
  static final double LARGE = dp(40);

  /// 卡片 圆角
  static final double LAYOUT_R_4 = 4.r;

  /// 卡片 圆角
  static final double LAYOUT_R_8 = 8.r;

  /// 卡片 圆角
  static final double LAYOUT_R_10 = 10.r;

  /// 卡片 圆角
  static final double LAYOUT_R_50 = 50.r;

  /// bar高度
  static final double appbar_h = 44.w;
}
